﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP.Classes;
namespace ERP.Hoadon
{
    public partial class viewErp_Xacnhan_BHTT : DevExpress.XtraEditors.XtraForm
    {
        public cs_erp_hoadonInfo hoadon = new cs_erp_hoadonInfo();
        public cs_hmr_usersInfo user = new cs_hmr_usersInfo();
        public cs_erp_hanghoaInfo hanghoa = new cs_erp_hanghoaInfo();
        public cs_erp_khohangInfo kho = new cs_erp_khohangInfo();
        public cs_erp_nhapkhoInfo nk = new cs_erp_nhapkhoInfo();
        int count = 0;
        public int flag = 1;

        public viewErp_Xacnhan_BHTT()
        {
            InitializeComponent();
        }

        private void viewErp_Xacnhan_BHTT_Load(object sender, EventArgs e)
        {
            this.Load_Combo();
        }
        private void Load_Combo()
        {
            DataSet ds = new DataSet("ds");
            //this.hanghoa.Get_List = this.kh.id_kh;
            ds = this.kho.Get_List();
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                //this.count = 0;
            }
            else
            {
                //this.cboKhonhap.Properties.DataSource = ds.Tables[0];
                this.cboKhoxuat.Properties.DataSource = ds.Tables[0];
            }
        }

        private void Save_Info()
        {
            this.nk.id_hd = this.hoadon.id_hd;
            //this.nk.makho = Convert.ToInt32(this.cboKhonhap.EditValue.ToString().Trim());

            this.nk.Get_Info();
            this.nk.manx = 2;
            this.nk.id_lannhap = -1;
            this.nk.ngaynhap = DateTime.Now;
            this.nk.nguoinhap = this.user.id_nv;
            this.nk.noidung = "Xuất kho BHTT Hóa đơn: " + this.hoadon.sohd;
            this.nk.sohd = this.hoadon.sohd;
            this.nk.ghichu = "Xuất hàng bán từ hóa đơn bán hàng trực tiếp";
            this.nk.makho = Convert.ToInt32(this.cboKhoxuat.EditValue.ToString().Trim());
            this.nk.trangthai = 1;
        }

        private void btnHoanthien_Click(object sender, EventArgs e)
        {
            //this.Save_Info();
            this.hoadon.trangthai = 5;
            this.hoadon.ExcuteProcedure(2);
            this.Save_Info();
            this.nk.ExcuteProcedure(5);
            this.Dispose(true);
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Dispose(true);
        }
    }
}